package com.wifi.a007.wifiFragment;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wifi.a007.R;
import com.wifi.a007.db.Word;

import java.util.List;

/**
 * Created by Administrator on 2017/7/13.
 */

public class WordAdapter extends RecyclerView.Adapter<WordAdapter.ViewHolder> {
    private List<Word> mWordList;


    public WordAdapter(List<Word> mWordList) {
        this.mWordList = mWordList;
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView wordName;
        TextView wordMeans;
        View wordView;

        public ViewHolder(View view){


            super(view);
            wordView= view;
            wordName=(TextView) view.findViewById(R.id.wordName);
            wordMeans =(TextView) view.findViewById(R.id.wordMeans);

        }




    }

    @Override
    public int getItemCount() {

        return mWordList.size();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {



        View  view= LayoutInflater.from(parent.getContext()).inflate(R.layout.word_item,parent,false);
        final ViewHolder holder = new ViewHolder(view);




        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        Word word=mWordList.get(position);
        holder.wordName.setText(word.getWordName());
        holder.wordMeans.setText(word.getWordmeans());


    }
}
